import 'package:changxindianzishangwu/cache/local_cache.dart';
import 'package:changxindianzishangwu/http/base/ec_base_request.dart';
import 'package:changxindianzishangwu/http/request/friends_circle_list_request.dart';
import 'package:changxindianzishangwu/http/request/friends_circle_list_user_request.dart';
import 'package:changxindianzishangwu/http/request/friends_lately.dart';
import 'package:changxindianzishangwu/http/request/friends_msg_delete_request.dart';
import 'package:changxindianzishangwu/http/request/friends_user_request.dart';
import 'package:changxindianzishangwu/http/zd_net.dart';
import 'package:changxindianzishangwu/model/friends_circle_model.dart';
import 'package:changxindianzishangwu/model/user_info_model.dart';
import 'package:changxindianzishangwu/model/friends_lately_model.dart';

/**
 * 2021.7.15
 * 获取朋友圈列表
 */
class FriendsCircleDao {

  ///获取自己的朋友圈信息
  static getFriendsCircleList(int page, String userId, bool isOpen) async {
    EcBaseRequest request = isOpen
        ? new FriendsCircleListUserRequest() //查看单个用户朋友圈
        : new FriendsCircleListRequest();
    request.add("pageIndex", page).add("userId", userId).add("isOpen", isOpen).add("pageSize", 10);
    request.add("access_token", getAppLoginToken());

    print('token:${getAppLoginToken()}');
    var result = await ZdNet.getInstance().send(request);
    return FriendsCircleModel.fromJson(result);
  }

  static getFriendsUserInfo(String userId) async {
    EcBaseRequest request = FriendsUserRequest();
    request.add("userId", userId);
    request.add("access_token", getAppLoginToken());

    print('token:${getAppLoginToken()}');
    var result = await ZdNet.getInstance().send(request);
    return UserInfoModel.fromJson(result);
  }
  static getFriendsLately(String userId) async {
    EcBaseRequest request = FriendsLatelyRequest();
    request.add("userId", userId);
    request.add("access_token", getAppLoginToken());

    var result = await ZdNet.getInstance().send(request);
    return FriendsLatelyModel.fromJson(result).data;
  }

  static deleteMsg(messageId)async{
    EcBaseRequest request = FriendsMsgDeleteRequest();
    request.add("messageId", messageId);
    request.add("access_token", getAppLoginToken());

    var result = await ZdNet.getInstance().send(request);
    return result["resultCode"];
  }

}
